﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AuctionSite.App_Code.Modelos;
using System.Data.SqlClient;

namespace AuctionSite.App_Code.DAL
{
    public class LeilaoDAL
    {
         public LeilaoDAL(){}

         public void Inserir(Leilao lei)
         {

             SqlConnection cn = new SqlConnection();
             try
             {

                 cn.ConnectionString = Dados.StringDeConexao;
                 //command
                 SqlCommand cmd = new SqlCommand();
                 cmd.Connection = cn;


                 cmd.CommandText = "INSERT INTO leilao (prod_id,data_win,valor,comprador,vendedor))VALUES (@prod_id,@data_win,@valor,@comprador,@vendedor);select @@IDENTITY;";
                 cmd.Parameters.AddWithValue("@prod_id", lei.Prod_id);
                 cmd.Parameters.AddWithValue("@data_win", lei.Data_win);
                 cmd.Parameters.AddWithValue("@valor", lei.Valor);
                 cmd.Parameters.AddWithValue("@comprador", lei.Comprador);
                 cmd.Parameters.AddWithValue("@vendedor", lei.Vendedor);
                 cn.Open();
                 cmd.ExecuteNonQuery();

                 cn.Close();


             }
             catch (SqlException ex)
             {
                 

             }




         }
    }
}